import { BasicColumn, FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
export const columns: BasicColumn[] = [
  // {
  //   title: '序号',
  //   dataIndex: 'did',
  //   width: 120,
  //   align: 'center',
  // },
  {
    title: '设备位置',
    dataIndex: 'bid',
    align: 'center',
    width: 120,
  },
  {
    title: '楼层',
    dataIndex: 'pos',
    align: 'center',
    width: 120,
  },
  {
    title: '类型',
    dataIndex: 'type',
    align: 'center',
    width: 120,
  },
  {
    title: '设备配置IP',
    dataIndex: 'ip',
    align: 'center',
    width: 180,
  },
  {
    title: '设备端口号',
    dataIndex: 'port',
    align: 'center',
    width: 180,
  },
  {
    title: '设备地址',
    dataIndex: 'addr',
    align: 'center',
    width: 180,
  },
  {
    title: '费率',
    dataIndex: 'money',
    align: 'center',
    width: 120,
  },
  {
    title: 'pid',
    dataIndex: 'pid',
    align: 'center',
    width: 120,
  },
  {
    title: '状态',
    dataIndex: 'state',
    align: 'center',
    width: 120,
    customRender: ({ text }) => {
      return h(Tag, { color: text == 1 ? 'green' : 'gray' }, () => (text == 1 ? '正常' : text == 0 ? '无效' : '--'));
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'bid',
    label: '设备位置',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'pos',
    label: '楼层',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'type',
    label: '类型',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'addr',
    label: '设备地址',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'money',
    label: '费率',
    component: 'Input',
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '序号',
    field: 'did',
    component: 'Input',
    show: false,
  },
  {
    label: '设备位置',
    field: 'bid',
    component: 'Input',
  },
  {
    label: '楼层',
    field: 'pos',
    component: 'Input',
  },
  {
    label: '类型',
    field: 'type',
    component: 'Input',
  },
  {
    label: '设备配置IP',
    field: 'ip',
    component: 'Input',
  },
  {
    label: '设备端口号',
    field: 'port',
    component: 'Input',
  },
  {
    label: '设备地址  ',
    field: 'addr',
    component: 'Input',
  },
  {
    label: '费率',
    field: 'money',
    component: 'Input',
  },
  {
    label: 'pid',
    field: 'pid',
    component: 'Input',
  },
  {
    label: '当前状态',
    field: 'state',
    component: 'RadioButtonGroup',
    componentProps: {
      //options里面由一个一个的radio组成,支持disabled禁用
      options: [
        { label: '正常', value: 1 },
        { label: '无效', value: 0 },
      ],
    },
  },
];
